#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
#include<fcntl.h>
#include<unistd.h>

int main(int argc,const char* argv[]){
    if(argc != 3){
        return -1;
    }
    int fd_r = open(argv[1],O_RDONLY);
    if(fd_r == -1){
        perror("open err");
        return -1;
    }

    int fd_w = open(argv[2],O_RDWR | O_CREAT | O_TRUNC,0666);
    if(fd_w == -1){
        perror("open err");
        close(fd_r);
        return -1;
    }
    
    char ch[32]={0};
    while( 1 ){
        
        if(write(fd_w,ch,read(fd_r,ch,32)) <= 0){
            break;
        }
    }

    close(fd_r);
    close(fd_w);

    return 0;
}